************************************************************************************************
************************************************************************************************
**             																				  **
**																							  **
** REVEALING "MAFIA INC."? FINANCIAL CRISIS, ORGANIZED CRIME AND THE BIRTH OF NEW ENTERPRISES **
**																							  **
** 									       (MAIN ANALYSIS)									  **
**																							  **
************************************************************************************************
************************************************************************************************
************************************************************************************************

** NOTE:	
* Run on STATA 15 for MacOS Catalina and Windows 10
* To run it is required the installation of the  packages:
*															- spmap
* 															- reg2hdfespatial
* 															- ttable2
* 															- outreg2

*________________________________________ SETTING WORKING DIRECTORY
global dirin "PUT HERE THE DIRECTORY OF THE FOLDER RAW_DATA"
global dirin2 "PUT HERE THE DIRECTORY OF THE FOLDER CLEANED_DATA"
global dirout "PUT HERE THE DIRECTORY OF THE FOLDER RESULTS_MAIN_ANALYSIS"


*________________________________________ OPENING LOG FILE
log using ${dirout}Main_analysis.log, replace


*________________________________________ LOADING DATA
use ${dirin2}final_database.dta, clear


*________________________________________ FIGURES

******** FIGURE 1
spmap tmi_q3 using ${dirin}prov_coord if year==2007, id(_ID) fcolor(Greys) /*
*/ legend(label(1 "Excluded sample") label(2 "1st tertile") label(3 "2nd tertile") label(4 "3rd tertile") )
graph export ${dirout}fig1.eps, replace


******** FIGURE 2
preserve
keep mafia_n3 name_prov id
collapse mafia_n3, by(name_prov id)
merge 1:m  name_prov  using ${dirin}quarter.dta
drop _merge

xtset id date, q
gen diff_credit=(credit_tot-l4.credit_tot)/l4.credit_tot
drop if year==2003

bysort  date: egen NoMafia=mean(diff_credit) if mafia_n3==0
bysort  date: egen Mafia=mean(diff_credit) if mafia_n3==1
label var Mafia "Mafia"
label var NoMafia  "No Mafia"

twoway (line NoMafia date if mafia_n3==0, graphregion(color(white)) ytitle("Business loans - Variation over 4 quarters", s(small)) /*
*/ lwidth(0.7) lc(black)  xtitle("") ylabel(,labs(small)) xlab(176(1)215, labs(vsmall) angle(45)) xline(190, lc(black) lp(dash)) yline(0, lc(black) lp(dash)))/*
*/ (line Mafia date if mafia_n3==1, graphregion(color(white))  ytitle("Business loans - Variation over 4 quarters", s(small)) /*
*/ lwidth(0.7) lc(gray)  xtitle("") ylabel(,labs(small))  xlab(176(1)215, labs(vsmall) angle(45)) xline(190, lc(black) lp(dash)) yline(0, lc(black) lp(dash)))
graph export ${dirout}fig2.eps, replace
restore


******** FIGURE 3
preserve
import excel ${dirin}drugs.xlsx, sheet("Foglio1") firstrow clear
reshape long OffencesEcstasy OffencesAmp OffencesCocaine OffencesHeroin OffencesCannabis /*
*/ MeanpriceEcstasy MeanpriceAmp MeanpriceCocaine MeanpriceHeroin MeanpriceCannabis /*
*/ SeizuresKgEcstasy SeizuresKgAmp SeizuresKgCocaine SeizuresKgHeroin SeizuresKgCannabis /*
*/ SeizuresNumberEcstasy SeizuresNumberAmp SeizuresNumberCocaine SeizuresNumberHeroin /*
*/ SeizuresNumberCannabis Use, i(variable) j(year)

keep if year<=2013
label var Use "Drug use"

foreach var in OffencesEcstasy MeanpriceEcstasy SeizuresKgEcstasy SeizuresNumberEcstasy {
label var `var' "Ecstasy"
}
foreach var in OffencesAmp MeanpriceAmp SeizuresKgAmp SeizuresNumberAmp {
label var `var' "Amphetamines"
}
foreach var in OffencesCocaine MeanpriceCocaine SeizuresKgCocaine SeizuresNumberCocaine {
label var `var' "Cocaine"
}
foreach var in OffencesHeroin MeanpriceHeroin SeizuresKgHeroin SeizuresNumberHeroin {
label var `var' "Heroin"
}
foreach var in OffencesCannabis MeanpriceCannabis SeizuresKgCannabis SeizuresNumberCannabis {
label var `var' "Cannabis"
}

* Panel (a): Offences
twoway  (line OffencesAmp year if year>2005, lc(Greys) lp(dash)) (line OffencesCocaine year if year>2005, lc(black) lp(longdash))/*
*/ (line OffencesHeroin year if year>2005, lc(Grey) lp(dash_dot)) (line OffencesCannabis year  if year>2005, lc(Greys)), /*
*/ xlabel(2004(1)2013, labs(small)) xline(2006, lc(black) lp(dash)) title("(a): Offenses", c(black) s(small)) /*
*/ ytitle("Total offenses for drugs use", size(small))  xtitle("") ylabel(,labs(vsmall)) graphregion(color(white)) 
graph save ${dirout}fig3_a.gph, replace

* Panel (b): Seizure Nunmber
twoway  (line SeizuresNumberAmp year if year>2005, lc(Greys) lp(dash)) (line SeizuresNumberCocaine year if year>2005, lc(Greys) lp(longdash)) /*
*/ (line SeizuresNumberHeroin year if year>2005, lc(Greys) lp(dash_dot)) (line SeizuresNumberCannabis year if year>2005, lc(Greys)), /*
*/ xlabel(2004(1)2013, labs(small)) xline(2006, lc(black) lp(dash)) title("(b): Number of seizures", c(black) s(small)) /*
*/ ytitle("Total number of seizures", size(small))  xtitle("") ylabel(,labs(vsmall)) graphregion(color(white)) 
graph save ${dirout}fig3_b.gph, replace

* Panel (c): Seizure KG
twoway  (line SeizuresKgAmp year, lc(Greys) lp(dash)) (line SeizuresKgCocaine year, lc(Greys) lp(longdash)) /*
*/ (line SeizuresKgHeroin year, lc(Greys) lp(dash_dot)) (line SeizuresKgCannabis year, lc(Greys)), /*
*/ xlabel(2004(1)2013, labs(small)) xline(2006, lc(black) lp(dash)) title("(c): Quantity seized", c(black) s(small)) /*
*/ ytitle("Total seizures (Kg)", size(small))  xtitle("") ylabel(,labs(vsmall)) graphregion(color(white)) 
graph save ${dirout}fig3_c.gph, replace

* Panel (d): Price 
twoway  (line MeanpriceAmp year, lc(Greys) lp(dash)) (line MeanpriceCocaine year, lc(Greys) lp(longdash)) /*
*/ (line MeanpriceHeroin year, lc(Greys) lp(dash_dot)) (line MeanpriceCannabis year, lc(Greys)), /*
*/ xlabel(2004(1)2013, labs(small)) xline(2006, lc(black) lp(dash)) title("(d): Price", c(black) s(small)) /*
*/ ytitle("Mean price", size(small))  xtitle("") ylabel(,labs(vsmall)) graphregion(color(white)) 
graph save ${dirout}fig3_d.gph, replace

cd ${dirout}
graph combine fig3_a.gph fig3_b.gph fig3_c.gph fig3_d.gph, c(2) r(2) graphregion(color(white)) 
graph export ${dirout}fig3.eps, replace
restore


******** FIGURE 4
* Panel (a): Parallel trends 
bysort year: egen ebr_mafia=mean(new_std) if mafia_n3==1
bysort year: egen ebr_nomafia=mean(new_std) if mafia_n3==0
label var ebr_mafia "Mafia"
label var ebr_nomafia  "No Mafia"

twoway (line ebr_nomafia year if year>=2003, lwidth(0.7) lc(black)) /*
*/ (line ebr_mafia year if year>=2003, lwidth(0.7) lc(gray) lp(solid)) /*
*/ (lfit ebr_nomafia year if  mafia_n3==0 & year>=2003 & year<2007, color (black) lpattern(dash)) /*
*/ (lfit ebr_mafia year if  mafia_n3==1 &  year>=2003 & year<2007, color (gray) lpattern(dash)) /*
*/ (lfit ebr_nomafia year if  mafia_n3==0 & year>2005, color (black) lpattern(dash))/*
*/ (lfit ebr_mafia year if  mafia_n3==1 & year>2005, color (gray) lpattern(dash)), /*
*/ xlabel(2003 "(t-4)" 2004 "(t-3)" 2005 "(t-2)" 2006 "(t-1)" 2007 "(t)" /*
*/ 2008 "(t+1)" 2009 "(t+2)" 2010 "(t+3)" 2011 "(t+4)" 2012 "(t+5)" 2013 "(t+6)", angle(45) labs(small))/*
*/ title("(a): 2003 - 2013", s(small) c(black)) xline(2006, lp(dash) lc(black)) /*
*/ ytitle("Avg. num. of new enterprises (per 100,000 inh.)", size(vsmall)) /*
*/ xtitle("") ylabel(,labs(vsmall)) graphregion(color(white)) leg(order(1 2))
graph save ${dirout}fig4_a.gph, replace
drop ebr_mafia ebr_nomafia 

* Panel (b): Event study
reg2hdfespatial new_std_ln *_mafia_n3 year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north if year>=2003, /*
*/ timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
parmest, sav(${dirout}fig4_b, replace) level(90 95 99)label
test _b[year_7_mafia_n3]=_b[year_8_mafia_n3]=_b[year_9_mafia_n3]=0

preserve
use ${dirout}fig4_b.dta, clear
keep if strpos(parm, "mafia_n3")
set obs `=_N+1'
replace label="Mafia x (t-1)" if label==""
replace parm="year_10_mafia_n3" if parm==""
foreach var in estimate stderr dof t p min90 max90 min95 max95 min99 max99 {
replace `var'=0 if `var'==.
}
tab parm, sort
replace parm=subinstr(parm,"_mafia_n3","",.)
replace parm=subinstr(parm,"year_","",.)
destring parm, replace
labmask parm, values(label)
drop label
twoway (scatter estimate parm, mcolor(black) msymbol(circle) msize(small))/*
*/ (rcap min99 max99 parm, lcolor(gs10)) (rcap min95 max95 parm, lcolor(gs5)) (rcap min90 max90 parm, lcolor(black)),/*
*/ title("(b): 2003 - 2013", s(small) c(black)) xlabel(, valuelabels angle(0) labsize(vsmall)) xtitle("") legend(off) /*
*/ graphregion(color(white)) bgcolor(white) xlabel(7(1)17,angle(45) labs(small)) yline(0, lpattern(dash) lc(black)) /*
*/ xline(10, lc(black) lp(dash))  ytitle("Point estimate", s(vsmall)) ylabel(, labs(vsmall))
graph save ${dirout}fig4_b.gph, replace
restore

* Panel (c): Parallel trends - Extended
bysort year: egen ebr_mafia=mean(new_std) if mafia_n3==1
bysort year: egen ebr_nomafia=mean(new_std) if mafia_n3==0
label var ebr_mafia "Mafia"
label var ebr_nomafia  "No Mafia"

twoway (line ebr_nomafia year, lwidth(0.7) lc(black)) /*
*/ (line ebr_mafia year if year>=1997, lwidth(0.7) lc(gray) lp(solid)) /*
*/ (lfit ebr_nomafia year if  mafia_n3==0 & year<2007, color (black) lpattern(dash)) /*
*/ (lfit ebr_mafia year if  mafia_n3==1 &  year<2007, color (gray) lpattern(dash)) /*
*/ (lfit ebr_nomafia year if  mafia_n3==0 & year>2005, color (black) lpattern(dash)) /*
*/ (lfit ebr_mafia year if  mafia_n3==1 & year>2005, color (gray) lpattern(dash)), /*
*/ xlabel(1997 "(t-10)" 1998 "(t-9)" 1999 "(t-8)" 2000 "(t-7)" 2001 "(t-6)" 2002 "(t-5)" /*
*/ 2003 "(t-4)" 2004 "(t-3)" 2005 "(t-2)" 2006 "(t-1)" 2007 "(t)" 2008 "(t+1)" 2009 "(t+2)" /*
*/ 2010 "(t+3)" 2011 "(t+4)" 2012 "(t+5)" 2013 "(t+6)",  angle(45) labs(small)) /*
*/ title("(c): 1997 - 2013", s(small) c(black)) xline(2006, lp(dash) lc(black))  /*
*/ ytitle("Avg. num. new enterprises (per 100,000 inh.)", size(vsmall))  xtitle("") /*
*/ ylabel(,labs(vsmall)) graphregion(color(white)) leg(order(1 2))
graph save ${dirout}fig4_c.gph, replace
drop ebr_mafia ebr_nomafia 

* Panel (d): Event study - Extended
reg2hdfespatial new_std_ln *_mafia_n3 year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north year_1_north year_2_north year_3_north /*
*/ year_4_north year_5_north year_6_north, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
parmest, sav(${dirout}fig4_d, replace) level(90 95 99)label
test _b[year_7_mafia_n3]=_b[year_8_mafia_n3]=_b[year_9_mafia_n3]=_b[year_6_mafia_n3]=_b[year_5_mafia_n3]=_b[year_4_mafia_n3]=_b[year_3_mafia_n3]=_b[year_2_mafia_n3]=_b[year_1_mafia_n3]=0

preserve
use ${dirout}fig4_d.dta, clear
keep if strpos(parm, "mafia_n3")
set obs `=_N+1'
replace label="Mafia x (t-1)" if label==""
replace parm="year_10_mafia_n3" if parm==""
foreach var in estimate stderr dof t p min90 max90 min95 max95 min99 max99 {
replace `var'=0 if `var'==.
}
tab parm, sort
replace parm=subinstr(parm,"_mafia_n3","",.)
replace parm=subinstr(parm,"year_","",.)
destring parm, replace
labmask parm, values(label)
drop label
twoway (scatter estimate parm, mcolor(black) msymbol(circle) msize(small)) /*
*/ (rcap min99 max99 parm, lcolor(gs10)) (rcap min95 max95 parm, lcolor(gs5)) (rcap min90 max90 parm, lcolor(black)), /*
*/ title("(d): 1997 - 2013", s(small) c(black)) xlabel(, valuelabels angle(0) labsize(vsmall)) xtitle("") legend(off) /*
*/ graphregion(color(white)) bgcolor(white) xlabel(1(1)17,angle(45) labs(small)) yline(0, lpattern(dash) lc(black)) /*
*/ xline(10, lc(black) lp(dash))  ytitle("Point estimate", s(vsmall)) ylabel(, labs(vsmall))
graph save ${dirout}fig4_d.gph, replace
restore

cd ${dirout}
graph combine fig4_a.gph fig4_b.gph fig4_c.gph fig4_d.gph, c(2) graphregion(color(white))
graph export fig4.eps, replace


******** FIGURE 5
reg2hdfespatial new_std_ln *_mafia_n3 pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp  blood newspapers_ln year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north, timevar(year) panelvar(id) lat(latitude) /*
*/ lon(longitude) distcutoff(200) lagcutoff(11)
parmest, sav(${dirout}fig5, replace) level(90 95 99)label
test _b[year_7_mafia_n3]=_b[year_8_mafia_n3]=_b[year_9_mafia_n3]=0

preserve
use ${dirout}fig5.dta, clear
keep if strpos(parm, "mafia_n3")
set obs `=_N+1'
replace label="Mafia x (t-1)" if label==""
replace parm="year_10_mafia_n3" if parm==""
foreach var in estimate stderr dof t p min90 max90 min95 max95 min99 max99 {
replace `var'=0 if `var'==.
}
tab parm, sort
replace parm=subinstr(parm,"_mafia_n3","",.)
replace parm=subinstr(parm,"year_","",.)
destring parm, replace
labmask parm, values(label)
drop label
twoway (scatter estimate parm, mcolor(black) msymbol(circle) msize(small))/*
*/ (rcap min99 max99 parm, lcolor(gs10)) (rcap min95 max95 parm, lcolor(gs5)) (rcap min90 max90 parm, lcolor(black)), /*
*/ xlabel(, valuelabels angle(0) labsize(vsmall)) xtitle("") legend(off) graphregion(color(white)) bgcolor(white) /*
*/ xlabel(7(1)17,angle(45) labs(small)) yline(0, lpattern(dash) lc(black)) xline(10, lc(black) lp(dash))  /*
*/ ytitle("Point estimate") ylabel(, labs(small))
graph export ${dirout}fig5.eps, replace
restore


******** FIGURE 6
* Panel (a):  Construction
reg2hdfespatial construction_std_ln *_mafia_n3 pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp blood newspapers_ln year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
parmest, sav(${dirout}fig6_a, replace) level(90 95 99)label
preserve
use ${dirout}fig6_a.dta, clear
keep if strpos(parm, "mafia_n3")
set obs `=_N+1'
replace label="Mafia x (t-1)" if label==""
replace parm="year_10_mafia_n3" if parm==""
foreach var in estimate stderr dof t p min90 max90 min95 max95 min99 max99 {
replace `var'=0 if `var'==.
}
tab parm, sort
replace parm=subinstr(parm,"_mafia_n3","",.)
replace parm=subinstr(parm,"year_","",.)
destring parm, replace
labmask parm, values(label)
drop label
twoway (scatter estimate parm, mcolor(black) msymbol(circle) msize(small)) /*
*/ (rcap min99 max99 parm, lcolor(gs10)) (rcap min95 max95 parm, lcolor(gs5)) (rcap min90 max90 parm, lcolor(black)),/*
*/ title("(a): Construction", s(small) c(black)) xlabel(, valuelabels angle(0) labsize(vsmall)) xtitle("") legend(off) /*
*/ graphregion(color(white)) bgcolor(white) xlabel(7(1)17,angle(45) labs(small)) yline(0, lpattern(dash) lc(black)) /*
*/ xline(10, lc(black) lp(dash))  ytitle("Point estimate") ylabel(, labs(vsmall))
graph save ${dirout}fig6_a.gph, replace
restore

* Panel (b):  Limited Liability Companies
reg2hdfespatial limited_std_ln *_mafia_n3  pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp blood newspapers_ln year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
parmest, sav(${dirout}fig6_b, replace) level(90 95 99)label
preserve
use ${dirout}fig6_b.dta, clear
keep if strpos(parm, "mafia_n3")
set obs `=_N+1'
replace label="Mafia x (t-1)" if label==""
replace parm="year_10_mafia_n3" if parm==""
foreach var in estimate stderr dof t p min90 max90 min95 max95 min99 max99 {
replace `var'=0 if `var'==.
}
tab parm, sort
replace parm=subinstr(parm,"_mafia_n3","",.)
replace parm=subinstr(parm,"year_","",.)
destring parm, replace
labmask parm, values(label)
drop label
twoway (scatter estimate parm, mcolor(black) msymbol(circle) msize(small)) /*
*/ (rcap min99 max99 parm, lcolor(gs10)) (rcap min95 max95 parm, lcolor(gs5)) (rcap min90 max90 parm, lcolor(black)),/*
*/ title("(b): Limited companies", s(small) c(black)) xlabel(, valuelabels angle(0) labsize(vsmall)) xtitle("") legend(off) /*
*/ graphregion(color(white)) bgcolor(white) xlabel(7(1)17,angle(45) labs(small)) yline(0, lpattern(dash) lc(black)) /*
*/ xline(10, lc(black) lp(dash))  ytitle("Point estimate") ylabel(, labs(vsmall))
graph save ${dirout}fig6_b.gph, replace
restore

* Panel (c):  Research
reg2hdfespatial ric_std_ln *_mafia_n3  pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp blood newspapers_ln year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
parmest, sav(${dirout}fig6_c, replace) level(90 95 99)label
preserve
use ${dirout}fig6_c.dta, clear
keep if strpos(parm, "mafia_n3")
set obs `=_N+1'
replace label="Mafia x (t-1)" if label==""
replace parm="year_10_mafia_n3" if parm==""
foreach var in estimate stderr dof t p min90 max90 min95 max95 min99 max99 {
replace `var'=0 if `var'==.
}
tab parm, sort
replace parm=subinstr(parm,"_mafia_n3","",.)
replace parm=subinstr(parm,"year_","",.)
destring parm, replace
labmask parm, values(label)
drop label
twoway (scatter estimate parm, mcolor(black) msymbol(circle) msize(small)) /*
*/ (rcap min99 max99 parm, lcolor(gs10)) (rcap min95 max95 parm, lcolor(gs5)) (rcap min90 max90 parm, lcolor(black)),/*
*/ title("(c): R&D", s(small) c(black)) xlabel(, valuelabels angle(0) labsize(vsmall)) xtitle("") legend(off) /*
*/ graphregion(color(white)) bgcolor(white) xlabel(7(1)17,angle(45) labs(small)) yline(0, lpattern(dash) lc(black)) /*
*/ xline(10, lc(black) lp(dash))  ytitle("Point estimate") ylabel(, labs(vsmall))
graph save ${dirout}fig6_c.gph, replace
restore

* Panel (d):  GDP
reg2hdfespatial ln_gdp *_mafia_n3  pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp blood newspapers_ln year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
parmest, sav(${dirout}fig6_d, replace) level(90 95 99)label
preserve
use ${dirout}fig6_d.dta, clear
keep if strpos(parm, "mafia_n3")
set obs `=_N+1'
replace label="Mafia x (t-1)" if label==""
replace parm="year_10_mafia_n3" if parm==""
foreach var in estimate stderr dof t p min90 max90 min95 max95 min99 max99 {
replace `var'=0 if `var'==.
}
tab parm, sort
replace parm=subinstr(parm,"_mafia_n3","",.)
replace parm=subinstr(parm,"year_","",.)
destring parm, replace
labmask parm, values(label)
drop label
twoway (scatter estimate parm, mcolor(black) msymbol(circle) msize(small)) /*
*/ (rcap min99 max99 parm, lcolor(gs10)) (rcap min95 max95 parm, lcolor(gs5)) (rcap min90 max90 parm, lcolor(black)),/*
*/ title("(d): GDP per capita", s(small) c(black)) xlabel(, valuelabels angle(0) labsize(vsmall)) xtitle("") legend(off) /*
*/ graphregion(color(white)) bgcolor(white) xlabel(7(1)17,angle(45) labs(small)) yline(0, lpattern(dash) lc(black)) /*
*/ xline(10, lc(black) lp(dash))  ytitle("Point estimate") ylabel(, labs(vsmall))
graph save ${dirout}fig6_d.gph, replace
restore

* Panel (e):  Unemployment rate
reg2hdfespatial un_rate *_mafia_n3  pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp blood newspapers_ln year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
parmest, sav(${dirout}fig6_e, replace) level(90 95 99)label
preserve
use ${dirout}fig6_e.dta, clear
keep if strpos(parm, "mafia_n3")
set obs `=_N+1'
replace label="Mafia x (t-1)" if label==""
replace parm="year_10_mafia_n3" if parm==""
foreach var in estimate stderr dof t p min90 max90 min95 max95 min99 max99 {
replace `var'=0 if `var'==.
}
tab parm, sort
replace parm=subinstr(parm,"_mafia_n3","",.)
replace parm=subinstr(parm,"year_","",.)
destring parm, replace
labmask parm, values(label)
drop label
twoway (scatter estimate parm, mcolor(black) msymbol(circle) msize(small)) /*
*/ (rcap min99 max99 parm, lcolor(gs10)) (rcap min95 max95 parm, lcolor(gs5)) (rcap min90 max90 parm, lcolor(black)),/*
*/ title("(e): Unemployment rate", s(small) c(black)) xlabel(, valuelabels angle(0) labsize(vsmall)) xtitle("") legend(off) /*
*/ graphregion(color(white)) bgcolor(white) xlabel(7(1)17,angle(45) labs(small)) yline(0, lpattern(dash) lc(black)) /*
*/ xline(10, lc(black) lp(dash))  ytitle("Point estimate") ylabel(, labs(vsmall))
graph save ${dirout}fig6_e.gph, replace
restore

* Panel (f):  Export/GDP
reg2hdfespatial tot_exp_r *_mafia_n3  pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp blood newspapers_ln year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
parmest, sav(${dirout}fig6_f, replace) level(90 95 99)label
preserve
use ${dirout}fig6_f.dta, clear
keep if strpos(parm, "mafia_n3")
set obs `=_N+1'
replace label="Mafia x (t-1)" if label==""
replace parm="year_10_mafia_n3" if parm==""
foreach var in estimate stderr dof t p min90 max90 min95 max95 min99 max99 {
replace `var'=0 if `var'==.
}
tab parm, sort
replace parm=subinstr(parm,"_mafia_n3","",.)
replace parm=subinstr(parm,"year_","",.)
destring parm, replace
labmask parm, values(label)
drop label
twoway (scatter estimate parm, mcolor(black) msymbol(circle) msize(small)) /*
*/ (rcap min99 max99 parm, lcolor(gs10)) (rcap min95 max95 parm, lcolor(gs5)) (rcap min90 max90 parm, lcolor(black)),/*
*/ title("(f): Export/GDP", s(small) c(black)) xlabel(, valuelabels angle(0) labsize(vsmall)) xtitle("") legend(off) /*
*/ graphregion(color(white)) bgcolor(white) xlabel(7(1)17,angle(45) labs(small)) yline(0, lpattern(dash) lc(black)) /*
*/ xline(10, lc(black) lp(dash))  ytitle("Point estimate") ylabel(, labs(vsmall))
graph save ${dirout}fig6_f.gph, replace
restore

* Panel (g):  Pubblic Procurement
reg2hdfespatial proc_std_ln *_mafia_n3  pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp blood newspapers_ln year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
parmest, sav(${dirout}fig6_g, replace) level(90 95 99)label
preserve
use ${dirout}fig6_g.dta, clear
keep if strpos(parm, "mafia_n3")
set obs `=_N+1'
replace label="Mafia x (t-1)" if label==""
replace parm="year_10_mafia_n3" if parm==""
foreach var in estimate stderr dof t p min90 max90 min95 max95 min99 max99 {
replace `var'=0 if `var'==.
}
tab parm, sort
replace parm=subinstr(parm,"_mafia_n3","",.)
replace parm=subinstr(parm,"year_","",.)
destring parm, replace
labmask parm, values(label)
drop label
twoway (scatter estimate parm, mcolor(black) msymbol(circle) msize(small)) /*
*/ (rcap min99 max99 parm, lcolor(gs10)) (rcap min95 max95 parm, lcolor(gs5)) (rcap min90 max90 parm, lcolor(black)),/*
*/ title("(g): Public procurement", s(small) c(black)) xlabel(, valuelabels angle(0) labsize(vsmall)) xtitle("") legend(off) /*
*/ graphregion(color(white)) bgcolor(white) xlabel(7(1)17,angle(45) labs(small)) yline(0, lpattern(dash) lc(black)) xline(10, lc(black) lp(dash))  /*
*/ ytitle("Point estimate") ylabel(, labs(vsmall))
graph save ${dirout}fig6_g.gph, replace
restore

* Panel (h):  EU funds
reg2hdfespatial fund_eu_std year_12_mafia_n3 year_13_mafia_n3 year_14_mafia_n3 year_15_mafia_n3 year_16_mafia_n3 year_17_mafia_n3 /*
*/ pop_urb tourism trial wastes_xc big_banks self_emp blood newspapers_ln year_11_north year_12_north /*
*/ year_13_north year_14_north year_15_north year_16_north year_17_north year_7_north year_8_north year_9_north if year>2006,/*
*/ timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
parmest, sav(${dirout}fig6_h, replace) level(90 95 99)label
preserve
use ${dirout}fig6_h.dta, clear
keep if strpos(parm, "mafia_n3")
set obs `=_N+1'
replace label="Mafia x (t)" if label==""
replace parm="year_11_mafia_n3" if parm==""
foreach var in estimate stderr dof t p min90 max90 min95 max95 min99 max99 {
replace `var'=0 if `var'==.
}
tab parm, sort
replace parm=subinstr(parm,"_mafia_n3","",.)
replace parm=subinstr(parm,"year_","",.)
destring parm, replace
labmask parm, values(label)
drop label
twoway (scatter estimate parm, mcolor(black) msymbol(circle) msize(small)) /*
*/ (rcap min99 max99 parm, lcolor(gs10)) (rcap min95 max95 parm, lcolor(gs5)) (rcap min90 max90 parm, lcolor(black)),/*
*/ title("(h): EU funds", s(small) c(black)) xlabel(, valuelabels angle(0) labsize(vsmall)) xtitle("") legend(off) /*
*/ graphregion(color(white)) bgcolor(white) xlabel(11(1)17,angle(45) labs(small)) yline(0, lpattern(dash) lc(black)) /*
*/ ytitle("Point estimate") ylabel(, labs(vsmall))
graph save ${dirout}fig6_h.gph, replace
restore

cd ${dirout}
graph combine fig6_a.gph  fig6_b.gph  fig6_c.gph fig6_d.gph fig6_e.gph fig6_f.gph fig6_g.gph fig6_h.gph, /*
*/ graphregion(color(white))
graph export ${dirout}fig6.eps, replace


******** FIGURE 7
* Panel (a): Closed enterprises
reg2hdfespatial closed_std_ln *_mafia_n3 pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp  blood newspapers_ln year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north if year>=2003, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
parmest, sav(${dirout}fig7_a, replace) level(90 95 99)label
test _b[year_7_mafia_n3]=_b[year_8_mafia_n3]=_b[year_9_mafia_n3]=0

preserve
use ${dirout}fig7_a.dta, clear
keep if strpos(parm, "mafia_n3")
set obs `=_N+1'
replace label="Mafia x (t-1)" if label==""
replace parm="year_10_mafia_n3" if parm==""
foreach var in estimate stderr dof t p min90 max90 min95 max95 min99 max99 {
replace `var'=0 if `var'==.
}
tab parm, sort
replace parm=subinstr(parm,"_mafia_n3","",.)
replace parm=subinstr(parm,"year_","",.)
destring parm, replace
labmask parm, values(label)
drop label
twoway (scatter estimate parm, mcolor(black) msymbol(circle) msize(small))/*
*/ (rcap min99 max99 parm, lcolor(gs10)) (rcap min95 max95 parm, lcolor(gs5)) (rcap min90 max90 parm, lcolor(black)),/*
*/ title("(a): Closed enterprises", s(small) c(black)) xlabel(, valuelabels angle(0) labsize(vsmall)) xtitle("") legend(off) /*
*/ graphregion(color(white)) bgcolor(white) xlabel(7(1)17,angle(45) labs(small)) yline(0, lpattern(dash) lc(black)) /*
*/ xline(10, lc(black) lp(dash))  ytitle("Point estimate", s(small)) ylabel(, labs(vsmall))
graph save ${dirout}fig7_a.gph, replace
restore


* Panel (b): Registered enterprises
reg2hdfespatial registered_std_ln *_mafia_n3 pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp  blood newspapers_ln year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north if year>=2003, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
parmest, sav(${dirout}fig7_b, replace) level(90 95 99)label
test _b[year_7_mafia_n3]=_b[year_8_mafia_n3]=_b[year_9_mafia_n3]=0

preserve
use ${dirout}fig7_b.dta, clear
keep if strpos(parm, "mafia_n3")
set obs `=_N+1'
replace label="Mafia x (t-1)" if label==""
replace parm="year_10_mafia_n3" if parm==""
foreach var in estimate stderr dof t p min90 max90 min95 max95 min99 max99 {
replace `var'=0 if `var'==.
}
tab parm, sort
replace parm=subinstr(parm,"_mafia_n3","",.)
replace parm=subinstr(parm,"year_","",.)
destring parm, replace
labmask parm, values(label)
drop label
twoway (scatter estimate parm, mcolor(black) msymbol(circle) msize(small))/*
*/ (rcap min99 max99 parm, lcolor(gs10)) (rcap min95 max95 parm, lcolor(gs5)) (rcap min90 max90 parm, lcolor(black)), /*
*/ title("(b): Registered enterprises", s(small) c(black)) xlabel(, valuelabels angle(0) labsize(vsmall)) xtitle("") legend(off) /*
*/ graphregion(color(white)) bgcolor(white) xlabel(7(1)17,angle(45) labs(small)) yline(0, lpattern(dash) lc(black)) /*
*/ xline(10, lc(black) lp(dash))  ytitle("Point estimate", s(small)) ylabel(, labs(vsmall))
graph save ${dirout}fig7_b.gph, replace
restore


cd ${dirout}
graph combine fig7_a.gph fig7_b.gph, graphregion(color(white)) ycommon
graph export ${dirout}fig7.eps, replace



*________________________________________ TABLES

******** TABLE 1
preserve
keep if year>=2003 & year<=2006 
collapse big_banks pop_urb wastes_xc tourism self_emp  trial blood newspapers mafia_n3, by(name_prov)
ttable2 big_banks self_emp tourism wastes_xc trial pop_urb newspapers blood, by(mafia_n3) format(%10.3f) 
restore


******** TABLE 2
** Col. (1): Prov FE + crisis
local vtext: var label new_std_ln
reg2hdfespatial new_std_ln crisis_mafia_n3_int if year>=2003, timevar(crisis) panelvar(id)  lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
outreg2 using ${dirout}tab2, label nonotes replace keep(crisis_mafia_n3_int) nocons /*
*/ addtext(Prov. FE, YES, Year FE, NO, North X Year FE, NO, Controls, NO)  ct("`vtext'") tex(frag) text dec(3) 

** Col. (2): Prov FE + year FE
reg2hdfespatial new_std_ln crisis_mafia_n3_int if year>=2003, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
outreg2 using ${dirout}tab2, label nonotes keep(crisis_mafia_n3_int) nocons /*
*/ addtext(Prov. FE, YES, Year FE, YES, North X Year FE, NO, Controls, NO)  ct("`vtext'") tex(frag) text dec(3) 

** Col. (3): Prov FE + year FE + North X Year FE
reg2hdfespatial new_std_ln crisis_mafia_n3_int year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north if year>=2003, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
outreg2 using ${dirout}tab2, label nonotes keep(crisis_mafia_n3_int) nocons /*
*/ addtext(Prov. FE, YES, Year FE, YES, North X Year FE, YES, Controls, NO)  ct("`vtext'") tex(frag) text dec(3) 

** Col. (4): Prov FE + year FE +  Controls
reg2hdfespatial new_std_ln crisis_mafia_n3_int   pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp  blood newspapers_ln if year>=2003, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
outreg2 using ${dirout}tab2, label nonotes keep(crisis_mafia_n3_int) nocons /*
*/ addtext(Prov. FE, YES, Year FE, YES, North X Year FE, NO, Controls, YES)  ct("`vtext'") tex(frag) text dec(3) 

** Col. (5): Prov FE + year FE + Controls + North X Year FE
sum new_std if crisis==0 & mafia_n3==1 & year>2003
local mean_new=r(mean)
sum pop_tot if crisis==0 & mafia_n3==1  & year>2003 /*this is 853005*/
reg2hdfespatial new_std_ln crisis_mafia_n3_int   pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp  blood newspapers_ln year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north if year>=2003, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11)
outreg2 using ${dirout}tab2, label nonotes keep(crisis_mafia_n3_int) nocons /*
*/ addtext(Prov. FE, YES, Year FE, YES, North X Year FE, YES, Controls, YES)  ct("`vtext'") tex(frag) text dec(3) 
local beta=_b[crisis_mafia_n3_int]
local effect= round(`beta'*`mean_new'*(853005/100000))
display "`effect'"


******** TABLE 3
** Col. (1): Closed ent.
local vtext: var label closed_std_ln
reg2hdfespatial closed_std_ln crisis_mafia_n3_int pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp  blood newspapers_ln  year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north if year>=2003, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11) 
outreg2 using ${dirout}tab3, label nonotes keep(crisis_mafia_n3_int) nocons replace/*
*/ addtext(Prov. FE, YES, Year FE, YES, North X Year FE, YES, Controls, YES)  ct("`vtext'") tex(frag) text dec(3) 

** Col. (2): Registered ent.
local vtext: var label registered_std_ln
reg2hdfespatial registered_std_ln crisis_mafia_n3_int pop_urb tourism trial wastes_xc big_banks /*
*/ self_emp blood newspapers_ln year_11_north year_12_north year_13_north year_14_north year_15_north /*
*/ year_16_north year_17_north year_7_north year_8_north year_9_north if year>=2003, timevar(year) panelvar(id) lat(latitude) lon(longitude) distcutoff(200) lagcutoff(11) 
outreg2 using ${dirout}tab3, label nonotes keep(crisis_mafia_n3_int) nocons /*
*/ addtext(Prov. FE, YES, Year FE, YES, North X Year FE, YES, Controls, YES)  ct("`vtext'") tex(frag) text dec(3) 


log close

